package hcn.protocol.ods.report;

import ctd.util.annotation.DicMapping;
import ctd.util.annotation.MappingType;
import ctd.util.xml.jaxb.DateTimeAdapter;
import hcn.protocol.ods.CardBean;
import org.apache.commons.lang3.StringUtils;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * Created by jinxin on 2016/5/18.
 */
@XmlRootElement(name = "patient")
public class PatientBean implements Serializable {

    private static final long serialVersionUID = -7903804343262794932L;

    private String certificateType;
    private String certificateNo;
    private String nationNo = "01";
    private String regionCode;
    private String patientName;
    private String name;
    private String sex;
    private Date dob;
    @DicMapping(dic = "cardType&hcn-mpi-dictionary-cardType", innerField = "cardType", type = MappingType.LIST)
    private List<CardBean> cards;

    //默认构造函数没有会报错
    public PatientBean() {
    }

    public PatientBean(List<CardBean> cards, String certificateNo, String certificateType, String nationNo) {
        this.cards = cards;
        this.certificateNo = certificateNo;
        this.certificateType = certificateType;
        this.nationNo = nationNo;
    }

    public String getCertificateType() {
        return certificateType;
    }

    public void setCertificateType(String certificateType) {
        this.certificateType = certificateType;
    }

    public String getCertificateNo() {
        return certificateNo;
    }

    public void setCertificateNo(String certificateNo) {
        this.certificateNo = certificateNo;
    }

    public String getNationNo() {
        return nationNo;
    }

    public void setNationNo(String nationNo) {
        this.nationNo = nationNo;
    }

    public String getRegionCode() {
        return regionCode;
    }

    public void setRegionCode(String regionCode) {
        this.regionCode = regionCode;
    }

    public String getPatientName() {
        if (StringUtils.isEmpty(patientName) && StringUtils.isNotEmpty(name))
            return name;
        return patientName;
    }

    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }

    public String getName() {
        if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(patientName))
            return patientName;
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    @XmlJavaTypeAdapter(DateTimeAdapter.class)
    public Date getDob() {
        return dob;
    }

    public void setDob(Date dob) {
        this.dob = dob;
    }

    @XmlElementWrapper(name = "cards")
    @XmlElement(name = "card")
    public List<CardBean> getCards() {
        return cards;
    }

    public void setCards(List<CardBean> cards) {
        this.cards = cards;
    }
}
